package edu.unc.comp410.colemangeer.model.object;


import org.apache.log4j.Logger;



/**
 * Associates an integer ID with each object
 * in the Model Layer that is saved in the DB.
 * 
 */
public abstract class PersistentObject extends MutableObject {
	
	private static int nextUnusedId = 1000;
	
		// Data members.
	private Integer id;
	private static final Integer NUM_FIELDS = 1;
	
		// Has the object been modified since its last
		// write to the DB? This is useful when implementing a
		// write back cache.
	//private Boolean dirty;
	private static Logger log = Logger.getLogger( PersistentObject.class );

	public PersistentObject( Integer theID ) {
		id = theID;
	}
	
	public PersistentObject() {
		id = getNextUnusedId();
	}

	public Integer getId() { return id; }
	
	public Integer getNextUnusedId() {
		return nextUnusedId++;
	}

	public static Integer getNumberOfDataFields() { return NUM_FIELDS; }
	
	public static Object string2Object( String str ) {
		return new Object();
	}

	/**
	 * Model Layer code should generally not change the
	 * value of the DB identifier. This is
	 * "protected" to accommodate the rare exceptions.
	 * @param id
	 */
	protected void setId(Integer theId) {
		this.id = theId;
	}
}
